package com.joysuch.wwyt.bp.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.joysuch.wwyt.bp.bean.investigate.SimpleTaskAssign;
import com.joysuch.wwyt.bp.entity.BpInvestigateTaskAssign;
import com.joysuch.wwyt.bp.entity.BpInvestigateTaskHis;
import com.joysuch.wwyt.bp.entity.dto.DeleteInvestigateRecordDto;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author jwk
 * @since 2021-09-16
 */
@Repository
public interface BpInvestigateTaskAssignMapper extends BaseMapper<BpInvestigateTaskAssign> {

    List<Long> findUserIdsByTaskId(Long id);

    List<SimpleTaskAssign> selectSimpleAssignByTaskIds(@Param("list") List<Long> taskIds);


    List<SimpleTaskAssign> selectUserByTaskIds(@Param("list") List<Long> taskIds);

    List<SimpleTaskAssign> selectHistoryUserByTaskIds(@Param("list") List<Long> taskIds);

    /**
     * 迁移assign数据
     */
    List<Long> getIdByTaskId(@Param("list") Collection<Long> list);

    long copyAssignToHistoryByIds(@Param("list") Collection<Long> list);

    long deleteByIds(@Param("list") Collection<Long> list);

    List<Long> exitsHisIds(@Param("ids") List<Long> list);

    Integer findAssignsCount(@Param("taskId") Long taskId);

    void deleteByTaskIdsAndUserIdNe(@Param("taskIds") List<Long> taskIds, @Param("currentUserId") Long currentUserId);

    void deleteByTaskIdAndUserId(@Param("oldSourceTask") List<BpInvestigateTaskHis> oldSourceTask);

    void deleteByTaskIdAndUserIdNe(@Param("newSourceTask") List<DeleteInvestigateRecordDto> newSourceTask);

    List<Long> getHisAssignIdByTaskId(@Param("taskIds") List<Long> taskIds);

    long copyHisAssignToYearAssignByIds(@Param("ids") List<Long> ids, String year);

    void deleteHisAssignByIds(@Param("ids") List<Long> ids);

}
